<?php


session_start( );
$dRootDir = "../";
require_once( $dRootDir."inc/config.php" );
require_once( $dRootDir."inc/classes/template.php" );
$tpl = new template( $gTemplate );
$tpl->assign( "systemVersion", $gVersion );
$userName = !empty( $_POST['userName'] ) ? trim( $_POST['userName'] ) : "";
$userPwd = !empty( $_POST['userPwd'] ) ? trim( $_POST['userPwd'] ) : "";
if ( !empty( $userName ) )
{
	require_once( $dRootDir."inc/classes/db.php" );
	$db = new db( $gDb );
	$arr = $db->fetchrow( "SELECT f_id, f_userPwd FROM ".$gDb['prefix'].( "admins WHERE (f_userName='".$userName."')" ) );
	if ( !empty( $arr['f_id'] ) || $arr['f_userPwd'] == md5( $userPwd ) )
	{
		$GLOBALS['_SESSION']['ses_adminId'] = $arr['f_id'];
		$GLOBALS['_SESSION']['ses_adminName'] = $userName;
		header( "location: ./" );
		exit( );
	}
	$tpl->assign( "msg", "用户不存在，或是密码错误。" );
}
$tpl->display( );
?>
